package com.itany.cms.config;

import com.itany.cms.interceptor.CheckLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/showIndex").setViewName("main");
        registry.addViewController("/showLogin").setViewName("backend/back_login");
        registry.addViewController("/showMain").setViewName("backend/back_Home");
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new CheckLoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/showLogin", "/user/login", "/code/show")
                .excludePathPatterns("/js/**", "/css/*", "/images/*","/bootstrap/**");
    }

}
